#! /bin/bash
function installZmq(){
    echo "install zeromq..."
    tar zxvf  $zeroPath -C /opt
    cd /opt/$(basename $zeroPath .tar.gz)
    ./configure
    make install
    ldconfig
    tar zxvf  $pyzmqPath -C /opt
    cd /opt/$(basename $pyzmqPath .tar.gz)
    python setup.py build
    python setup.py install
    cd ..
    python -c "import zmq"
    if [ $? -ne 0 ]; then
        echo "install zmq error..."
        exit 1
    else
        echo "install zmq ok..."
    fi
}
function getPath() {
  zeroPath=$INSPECTOR_HOME/packages/zeromq-4.3.2.tar.gz
  pyzmqPath=$INSPECTOR_HOME/packages/pyzmq-19.0.0.tar.gz
  if [ ! -f "${zeroPath}" ]; then
    printTime
    echo ".........ERROR:Cannot read zeroPath from $INSPECTOR_HOME/packages"
    exit 1
  fi
  if [ ! -f "${pyzmqPath}" ]; then
    printTime
    echo ".........ERROR:Cannot read pyzmqPath from $INSPECTOR_HOME/packages"
    exit 1
  fi
  installZmq
}
function printTime() {
  echo -n $(date "+%Y-%m-%d %H:%M:%S")" "
}
function main() {
    getPath
}
main    